const state = {
  // 当前选中
  currentActor: {
    data: '',
    group: ''
  },
  // 所有模型
  modelGroup: {
    data: [],
    index: ''
  },
  // 所有交互
  activeGroup: {
    data: [],
    index: ''
  }
}

const getters = {
  // 选中实体具体信息
  queryCurrentActorData: state => state.currentActor.data,

  // 选中实体分组信息
  queryCurrentActorGroup: state => state.currentActor.group,

  // 查询所有的模型信息
  queryModelGroupData: state => state.modelGroup.data,

  // 查询所有模型当前选中的索引
  queryModelGroupIndex: state => state.modelGroup.index,

  // 查询所有的交互信息
  queryActiveGroupData: state => state.activeGroup.data,

  // 查询所有的交互的选中索引
  queryActiveGroupIndex: state => state.activeGroup.index,
}

// 同步数据
const mutations = {
  // 设置选中的实体信息
  setCurrentActor(state, data) {
    state.currentActor.data = data.data.Data;
    state.currentActor.group = data.group;
  },

  // 删除选中的实体信息
  removeCurrentActor(state, data) {
    state.currentActor.data = '';
  },

  // 设置选中的实体分组
  setCurrentActorGroup(state, data) {
    state.currentActor.group = data;
  },

  // 添加模型信息
  addModelGroup(state, data) {
    state.modelGroup.data.push(data.data);
    state.modelGroup.index = data.index;
  },

  // 设置模型选中索引
  setModelGroupIndex(state, data) {
    state.modelGroup.index = data;
  },

  // 添加交互信息
  addActiveGroup(state, data) {
    state.activeGroup.data.push(data.data);
    state.activeGroup.index = data.index;
  },

  // 设置交互选中索引
  setActiveGroupIndex(state, data) {
    state.activeGroup.index = data
  },

  // 清除所有分组信息
  clearAllGroup(state) {
    state.modelGroup.data = [];
    state.activeGroup.data = [];
  },

  // 移除当前索引的模型
  removeModelByIndex(state) {
    state.modelGroup.data.splice(state.modelGroup.index, 1);
  },

  // 移除当前索引的交互
  removeActiveByIndex(state) {
    state.activeGroup.data.splice(state.activeGroup.index, 1);
  },
}


export default {
  namespaced: true,
  state,
  mutations,
  getters
}